//
//  APGoodsViewCell.m
//  AqualPolo
//
//  Created by dong on 2024/5/9.
//

#import "APGoodsViewCell.h"

@implementation APGoodsViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = 8;
        [self setGradientBackgroundWithColors:@[LYRGBColor(45, 116, 255),LYRGBAColor(80, 216, 216, 0.2)] locations:@[@0,@1] startPoint:CGPointMake(0.5, 0) endPoint:CGPointMake(0.5, 1)];
        
        UIView *contentView = [[UIView alloc] init];
        contentView.userInteractionEnabled = false;
        contentView.layer.cornerRadius = 8;
        [self.contentView addSubview:contentView];
        [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self).insets(UIEdgeInsetsMake(1, 1, 1, 1));
        }];
        [contentView setGradientBackgroundWithColors:@[LYRGBColor(24, 56, 92),LYRGBColor(6, 52, 75)] locations:@[@0,@1] startPoint:CGPointMake(0.5, 0) endPoint:CGPointMake(0.5, 1)];
        
        _bigDealImageView = [[UIImageView alloc] init];
        _bigDealImageView.image = [UIImage imageNamed:@"goods_tag_bg"];
        [contentView addSubview:_bigDealImageView];
        [_bigDealImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(contentView.mas_top).offset(-10);
            make.right.equalTo(contentView.mas_right).offset(4);
            make.size.mas_equalTo(CGSizeMake(70, 25));
        }];
        
        _tagLabel = [[UILabel alloc] init];
        _tagLabel.textColor = [UIColor whiteColor];
        _tagLabel.font = [LYFont fontWithSize:12 fontName:LYFontNamepfr];
        _tagLabel.textAlignment = NSTextAlignmentCenter;
        [_bigDealImageView addSubview:_tagLabel];
        [_tagLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_bigDealImageView).offset(3);
            make.left.right.equalTo(_bigDealImageView);
            make.bottom.equalTo(_bigDealImageView).offset(-8);
        }];
        
        UIImageView *coinImageView = [[UIImageView alloc] init];
        coinImageView.image = [UIImage imageNamed:@"coin_icon_s"];
        [contentView addSubview:coinImageView];
        [coinImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(contentView).offset(28);
            make.centerX.equalTo(contentView);
            make.size.mas_equalTo(CGSizeMake(36, 35));
        }];
        
        _coinLabel = [[UILabel alloc] init];
        _coinLabel.textColor = [UIColor whiteColor];
        _coinLabel.font = [LYFont fontWithSize:20 fontName:LYFontNamepfb];
        _coinLabel.textAlignment = NSTextAlignmentCenter;
        [contentView addSubview:_coinLabel];
        [_coinLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(coinImageView.mas_bottom).offset(13);
            make.left.right.equalTo(contentView);
        }];
        
        _discountLabel = [[UILabel alloc] init];
        _discountLabel.textColor = LYRGBColor(1, 241, 178);
        _discountLabel.font = [LYFont fontWithSize:9 fontName:LYFontNamepfr];
        _discountLabel.textAlignment = NSTextAlignmentCenter;
        [contentView addSubview:_discountLabel];
        [_discountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_coinLabel.mas_bottom).offset(8);
            make.left.right.equalTo(contentView);
        }];
        
        _discountPriceLabel = [[UILabel alloc] init];
        _discountPriceLabel.textColor = [UIColor whiteColor];
        _discountPriceLabel.font = [LYFont fontWithSize:14 fontName:LYFontNamepfm];
        _discountPriceLabel.textAlignment = NSTextAlignmentLeft;
        [contentView addSubview:_discountPriceLabel];
        [_discountPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(contentView.mas_centerX).offset(-6);
            make.bottom.equalTo(contentView).offset(-12);
        }];
        
        _priceLabel = [[UILabel alloc] init];
        _priceLabel.textColor = LYRGBAColor(255, 255, 255, 0.3);
        _priceLabel.font = [LYFont fontWithSize:10 fontName:LYFontNamepfr];
        _priceLabel.textAlignment = NSTextAlignmentLeft;
        [contentView addSubview:_priceLabel];
        [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(contentView.mas_centerX).offset(6);
            make.bottom.equalTo(contentView).offset(-12);
        }];
        
    }
    return self;
}
@end
